#include <sys/ipc.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <unistd.h>

typedef struct
{
        char name;
  int age;
}people;
int main(int argc,char **argv)
{
     int shm_id,i;
     people *p_map;
     struct shmid_ds shmbuf;

     shm_id=393216;//393216是ipcs -m查看到的shmid
     p_map=(people*)shmat(shm_id,NULL,0);
     for(i=0;i<10;i++)
     {
        printf("name----------%c\n",(*(p_map+i)).name);
        printf("age------------%d\n",(*(p_map+i)).age);
     }
     if(shmdt(p_map)<0)
          perror("shmdt error");
     if(shmctl(shm_id,IPC_RMID,&shmbuf)<0)
          perror("shmctl error");
     
    return 0;
}
